package asteroids.model.programs.expressions.BasicExpressions;

import be.kuleuven.cs.som.annotate.Basic;
import asteroids.model.SpaceObject;
import asteroids.model.programs.expressions.BasicExpression;
import asteroids.model.programs.types.Type;


public class Entity extends BasicExpression {
	/**
	 * Initialize this new entity with given SpaceObject
	 *
	 * @param  entity
	 *         The SpaceObject for this new entity.
	 * @post   ...
	 *       | new.getEntity() == entity
	 */
	public Entity(SpaceObject entity, int line, int column){
		super(line, column);
		this.entity = entity;
	}
	
	/**
	 * returns the entity this object refers to.
	 * @return ...
	 * 			this.entity
	 */
	@Basic
	public SpaceObject getValue(){
		return this.entity;
	}
	
	/**
	 * Sets the entity to the given entity.
	 * @param newEntity
	 * 		  The entity that is to be set to.
	 * @post ...
	 * 		 (new this).entity = newEntity
	 */
	@Basic
	public void setEntity(SpaceObject newEntity){
		this.entity = newEntity;
	}
	
	private SpaceObject entity;

	/**
	 * @return returns this expression
	 * 			| return this
	 */
	@Override
	public BasicExpression getResult() {
		return this;
	}
	
	/**
	 * @return Returns the textual representation of this expression
	 * 			| return entity.getClass().toString()
	 */
	@Override
	public String toString() {
		return entity.getClass().toString();
	}
	
	@Override
	public Type getType(){
		return Type.ENTITY;
	}
}
